

class Solution:

    def search(self, nums, target):
        """
        :param nums: list[int]
        :param target: int
        :return: int
        """
        num_len = len(nums)
        left = 0
        right = num_len - 1
        while left <= right:
            mid_ = (left + right) / 2
            mid = int(mid_)
            if nums[mid] > target:
                right = mid - 1
            if nums[mid] < target:
                left = mid + 1
            if nums[mid] == target:
                print(mid)
                return mid
        if left > right:
            print(-1)
            return -1


if __name__ == '__main__':
    sol = Solution()
    sol.search(nums=[5], target=5)